package org.ma1.cripto.aes.operacion;

public class OperacionBuilder {
	
	public static final String ByteSub = "ByteStub";
	public static final String ShiftRow = "ShiftRow";
	public static final String MixColumns = "MixColumns";
	public static final String AddRoundKey = "AddRoundKey";
	public static final String ExtendKey = "ExtendKey";
	
	public static final String InvByteSub = "InvByteStub";
	public static final String InvShiftRow = "InvShiftRow";
	public static final String InvMixColumns = "InvMixColumns";
	public static final String InvAddRoundKey = "InvAddRoundKey";
	public static final String InvGenerateNewKey = "InvGenerateNewKey";
	
	private static OperacionBuilder instance = null;
	private OperacionBuilder() {}
	public static OperacionBuilder getCurrentInstance() {
		if (instance==null) {
			instance = new OperacionBuilder();
		}
		return instance;
	}
	public IOperacion createOperacion(String tipo) {
		IOperacion ret = null;
		if (tipo.equals(ByteSub)) {
			ret = new ByteSub();
		} else if (tipo.equals(ShiftRow)) {
			ret = new ShiftRows();
		} else if (tipo.equals(MixColumns)) {
			ret = new MixColumns();
		} else if (tipo.equals(AddRoundKey)) {
			ret = new AddRoundKey();
		} else if (tipo.equals(ExtendKey)) {
			ret = null; // FALTA EL GenerateNewKey
		} else if (tipo.equals(InvByteSub)) {
			ret = new InvByteSub();
		} else if (tipo.equals(InvShiftRow)) {
			ret = new InvShiftRows();
		} else if (tipo.equals(InvMixColumns)) {
			ret = new InvMixColumns();
		} else if (tipo.equals(InvAddRoundKey)) {
			ret = new InvAddRoundKey();
		} else {
			ret = null; // FALTA EL InvExtendKey
		}
		return ret;
	}
}
